﻿Option Explicit On

'*******************************************************************
' Program: xmlVisio
' Author: Albert E Edlund
' Date:
'
' Purpose:
' Working with visio drawing in an xml format
'
'
'
'*******************************************************************

Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Text
Imports System.Text.StringBuilder

Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging

Imports System.IO
Imports System.Windows.Forms
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Xml.Linq
Imports System.Xml.XPath

Imports <xmlns="http://schemas.microsoft.com/visio/2003/core">
Imports <xmlns:vx="http://schemas.microsoft.com/visio/2006/extension">
Imports <xmlns:v14="http://schemas.microsoft.com/office/visio/2010/extension">


Public Class frmPageShapes

#Region " Properties and Declarations "


    Private _dataPath As String
    Public Property dataPath As String
        Get
            dataPath = _dataPath
        End Get
        Set(value As String)
            _dataPath = value
        End Set
    End Property

    Public _xDoc As XDocument
    Public Property xDoc As XDocument
        Get
            Return Me._xDoc
        End Get
        Set(value As XDocument)
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("Value", _
                    "xDoc is Null.")
            End If
            Me._xDoc = value
        End Set
    End Property

 
    Private _shpDict As Dictionary(Of Long, String)
    Public Property dictShapes As Dictionary(Of Long, String)
        Get
            Return Me._shpDict
        End Get
        Set(value As Dictionary(Of Long, String))
            If (value Is Nothing) Then
                Throw New System.ArgumentNullException("Value", _
                    "dictShapes is Null.")
            End If
            Me._shpDict = value
        End Set
    End Property


    Private _strPgName As String
    Public Property strPgName As String
        Get
            strPgName = _strPgName
        End Get
        Set(value As String)
            _strPgName = value
        End Set
    End Property

    Private _strPgNameU As String
    Public Property strPgNameU As String
        Get
            strPgNameU = _strPgNameU
        End Get
        Set(value As String)
            _strPgNameU = value
        End Set
    End Property

    Private _lngPgId As Long
    Public Property lngPgId As Long
        Get
            lngPgId = _lngPgId
        End Get
        Set(value As Long)
            _lngPgId = value
        End Set
    End Property

    Private _PgSource As XElement
    Public Property PgSource As XElement
        Get
            PgSource = _PgSource
        End Get
        Set(value As XElement)
            _PgSource = value
        End Set
    End Property



    Private _strShpName As String
    Public Property strShpName As String
        Get
            strShpName = _strShpName
        End Get
        Set(value As String)
            _strShpName = value
        End Set
    End Property

    Private _strShpNameU As String
    Public Property strShpNameU As String
        Get
            strShpNameU = _strShpNameU
        End Get
        Set(value As String)
            _strShpNameU = value
        End Set
    End Property

    Private _lngShpId As Long
    Public Property lngShpId As Long
        Get
            lngShpId = _lngShpId
        End Get
        Set(value As Long)
            _lngShpId = value
        End Set
    End Property

    Private _strShpType As String
    Public Property strShpType As String
        Get
            strShpType = _strShpType
        End Get
        Set(value As String)
            _strShpType = value
        End Set
    End Property


    Private _ShpSource As XElement
    Public Property ShpSource As XElement
        Get
            ShpSource = _ShpSource
        End Get
        Set(value As XElement)
            _ShpSource = value
        End Set
    End Property


#End Region


    '
    ' load a list of page names and ids into a list control
    '
    Public Sub getPages _
        (ByRef lvControl As ListView)

        Try


            If lvControl Is Nothing Then lvControl = Me.lvPages

            Dim qryPages = xDoc...<Page>
            Dim intPages As Integer = qryPages.Count
            Dim docPage As XDocument

            lvControl.Items.Clear()
            lvControl.Columns.Clear()
            lvControl.View = View.Details
            lvControl.AllowColumnReorder = True
            lvControl.FullRowSelect = True
            lvControl.Columns.Add("Id", 50, HorizontalAlignment.Right)
            lvControl.Columns.Add("Name", 100, HorizontalAlignment.Left)
            lvControl.Columns.Add("NameU", 100, HorizontalAlignment.Left)


            For Each page In qryPages

                Dim lvItem As ListViewItem

                lngPgId = -1
                strPgName = "NoPgName"
                strPgNameU = "NoPgNameU"

                Dim listOfAttributes As IEnumerable(Of XAttribute) = _
                    From att In page.Attributes() _
                    Select att
                For Each att As XAttribute In listOfAttributes
                    ' Console.WriteLine("{0}={1}", att.Name.LocalName, att.Value)
                    Select Case LCase(att.Name.LocalName)
                        Case "id"
                            lngPgId = CLng(att.Value)
                        Case "name"
                            ' get the recordset name
                            strPgName = CStr(att.Value)
                        Case "nameu"
                            strPgNameU = CStr(att.Value)
                    End Select
                Next att

                lvItem = New ListViewItem(lngPgId)
                lvItem.SubItems.Add(strPgName)
                lvItem.SubItems.Add(strPgNameU)

                ' add it to the listview on the data page
                lvControl.Items.Add(lvItem)

                If lvControl.Items.Count = 1 And _
                    lvControl.Name = "lvPages" Then

                    PgSource = page
                    getShapes(page, Me.lvShapes)

                End If

            Next page

        Catch errXml As XmlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(errXml, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    ' pass in a datasource (doc or page) and get a list of shapes
    '
    Private Sub getShapes _
        (ByVal shapeSource As XElement, _
         ByRef lvControl As ListView)

        Try

            Dim colShapeIds As Collection = New Collection

            Dim qryShapes = shapeSource...<Shape>
            Dim intShapes As Integer = qryShapes.Count
            Dim lngParent As Long = -1

            lvControl.Items.Clear()
            lvControl.Columns.Clear()
            lvControl.View = View.Details
            lvControl.AllowColumnReorder = True
            lvControl.FullRowSelect = True
            lvControl.Columns.Add("Id", 50, HorizontalAlignment.Right)
            lvControl.Columns.Add("Name", 100, HorizontalAlignment.Left)
            lvControl.Columns.Add("NameU", 100, HorizontalAlignment.Left)
            lvControl.Columns.Add("Type", 100, HorizontalAlignment.Left)
            lvControl.Columns.Add("Parent", 50, HorizontalAlignment.Right)

            For Each shape In qryShapes

                Dim lvItem As ListViewItem

                lngShpId = -1
                strShpName = "NoShpName"
                strShpNameU = "NoShpNameU"
                strShpType = "NoShpType"

                Dim listOfAttributes As IEnumerable(Of XAttribute) = _
                    From att In shape.Attributes() _
                    Select att

                For Each att As XAttribute In listOfAttributes
                    ' Console.WriteLine("{0}={1}", att.Name.LocalName, att.Value)
                    Select Case LCase(att.Name.LocalName)
                        Case "id"
                            lngShpId = CLng(att.Value)
                        Case "name"
                            ' get the shape name
                            strShpName = CStr(att.Value)
                        Case "nameu"
                            strShpNameU = CStr(att.Value)
                        Case "type"
                            strShpType = CStr(att.Value)
                    End Select
                Next att

                ' add it to the listview control
                lvItem = New ListViewItem(lngShpId)
                lvItem.SubItems.Add(strShpName)
                lvItem.SubItems.Add(strShpNameU)
                lvItem.SubItems.Add(strShpType)
                lvItem.SubItems.Add(CStr(lngParent))

                ' add it to the listview on the data page
                lvControl.Items.Add(lvItem)

                ' add it to the local collection
                colShapeIds.Add(lngShpId)

                If lvControl.Items.Count = 1 And _
                    lvControl.Name = "lvShapes" Then

                    Me.txtShapeId.Text = CStr(lngShpId)
                    Me.txtShpName.Text = strShpName
                    Me.txtShpNameU.Text = strShpNameU

                    ' save the xElement
                    ShpSource = shape
                    ' scan it for contents
                    getShapeSheetInfo(lngShpId)

                End If

            Next shape

            Dim intShapeCt As Integer = colShapeIds.Count
            updateShapeParent(colShapeIds)

        Catch errXml As XmlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(errXml, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    ' go through the shapes and find out who the parent shape is for the complex
    ' grouped objects and then update the shapes listview control
    '
    Private Sub updateShapeParent(ByVal colShapes As Collection)

        Try


            ' get the list of descendant shapes
            Dim colReturned As Collection = New Collection
            Dim sbCollection As StringBuilder = New StringBuilder
            Dim dictShapeParents As Dictionary(Of Long, Long) = New Dictionary(Of Long, Long)
            Dim strReturn As String
            Dim attrShape As XElement

            For Each shapeid In colShapes

                ' put the shapeid into the dictionary
                If dictShapeParents.ContainsKey(shapeid) = False Then
                    dictShapeParents.Add(shapeid, -1)
                End If

                ' make the shapeid as string
                Dim strShapeId As String = CStr(shapeid)
                ' go find a shape with an ID = strShapeId on the active page
                Dim qryShapeInfo = From shpSel In Me.PgSource...<Shape> _
                    Where shpSel.@ID = strShapeId
                ' if we found the shape then look for "shapes" section - grouped shape
                If qryShapeInfo.Count = 1 Then
                    ' get the shapes sections
                    sbCollection.Clear()
                    ' go look for the "shapes" element to find the descendants
                    Dim qryAttrShapes = From shpGroup In qryShapeInfo...<Shapes>
                    Dim intAttrShapes As Integer = qryAttrShapes.Count
                    ' the "shapes" section may come back as multiples, i.e. groups within
                    ' groups
                    If 0 < intAttrShapes Then
                        ' so take the first shapes 
                        attrShape = qryAttrShapes.First
                        colReturned = getShapeChildren(attrShape)
                        'For Each shpChild In colReturned
                        '   strReturn = CStr(shpChild) & " "
                        '   sbCollection.Append(strReturn)
                        'Next
                        'Console.WriteLine("{0}={1}", strShapeId, sbCollection.ToString)

                        For Each shpChild In colReturned
                            dictShapeParents(shpChild) = shapeid
                        Next shpChild

                    End If ' test for "shapes" xelement found
                End If ' test for "shape" xelement found

            Next shapeid

            ' now update the parent column of the shapes listview
            Dim lngParent As Long
            Dim lvItem As ListViewItem
            Dim lngShape As Long

            For Each lvItem In lvShapes.Items
                lngShape = CLng(lvItem.Text)
                lngParent = dictShapeParents(lngShape)
                lvItem.SubItems(4).Text = CStr(lngParent)
            Next (lvItem)

        Catch errXml As XmlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(errXml, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try
    End Sub

    '
    ' get the shapesheet sections for the selected shape from the page source
    '
    Private Sub getShapeSheetInfo _
        (ByVal lngShapeId As Long)

        Try

            ' clear the active shape source
            ShpSource = Nothing

            Dim lngId As Long
            Dim strName As String
            Dim strNameU As String
            Dim strType As String

            _ShpSource = Nothing

            Dim strShapeId As String = CStr(lngShapeId)

            ' go find a shape with an ID = strShapeId on the active page
            Dim qryShapeInfo = From shpSel In Me.PgSource...<Shape> _
                Where shpSel.@ID = strShapeId

            Dim intShapeInfo As Integer = qryShapeInfo.Count

            Dim shape As XElement

            If intShapeInfo = 1 Then
                shape = qryShapeInfo.First
            Else
                Exit Sub
            End If

            lngId = -1
            strName = "NoShpName"
            strNameU = "NoShpNameU"
            strType = "NoShpType"

            Dim listOfAttributes As IEnumerable(Of XAttribute) = _
                From att In shape.Attributes() _
                Select att

            For Each att As XAttribute In listOfAttributes
                ' Console.WriteLine("{0}={1}", att.Name.LocalName, att.Value)
                Select Case LCase(att.Name.LocalName)
                    Case "id"
                        lngId = CLng(att.Value)
                    Case "name"
                        strName = att.Value.ToString
                    Case "nameu"
                        strNameU = att.Value.ToString
                    Case "type"
                        strType = att.Value.ToString
                End Select
            Next att


            Me.ShpSource = shape
            lngShpId = lngId
            strShpName = strName
            strShpNameU = strNameU
            Me.txtShpName.Text = strName
            Me.txtShpNameU.Text = strNameU
            Me.txtShapeId.Text = CStr(lngId)
            Me.txtShpType.Text = strType


            mapElementsOfActiveShape(shape)


        Catch errXml As XmlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(errXml, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try


    End Sub

    '
    ' examine shape to see what sections are loaded and then enable
    ' the appropriate command buttons
    '
    Private Sub mapElementsOfActiveShape(ByVal shape As XElement)

        If shape Is Nothing Then Exit Sub

        Try

            btnShapeData.Enabled = False
            btnUserData.Enabled = False
            btnScratchData.Enabled = False

            btnConnection.Enabled = False
            btnControl.Enabled = False

            btnxForm1d.Enabled = False
            btnxForm.Enabled = False
            btnLayout.Enabled = False
            btnLayerMem.Enabled = False

            btnText.Enabled = False
            btnTxtXForm.Enabled = False
            btnChar.Enabled = False
            btnParagraph.Enabled = False

            btnMisc.Enabled = False
            btnAction.Enabled = False
            btnProtection.Enabled = False
            btnEvent.Enabled = False
            ' give it time to catch up
            System.Windows.Forms.Application.DoEvents()


            Dim colChildren As Collection = New Collection

            ' start the shape drilldown
            Dim listOfElements As IEnumerable(Of XElement) = _
                    From elemData In shape.Elements() _
                    Select elemData

            For Each elem As XElement In listOfElements

                'Console.WriteLine(" {0} {1}={2}", strShpName, elem.Name.LocalName, elem.Value)

                Select Case LCase(elem.Name.LocalName)

                    Case "shapes"
                        ' get a list of subshape ids
                        ' colChildren = getShapeChildren(elem)
                        Exit Select
                    Case "user"
                        Me.btnUserData.Enabled = True
                        Exit Select
                    Case "prop"
                        Me.btnShapeData.Enabled = True
                        Exit Select
                    Case "scratch"
                        Me.btnScratchData.Enabled = True
                        Exit Select
                    Case "control"
                        Me.btnControl.Enabled = True
                        Exit Select
                    Case "connection"
                        Me.btnConnection.Enabled = True
                        Exit Select
                    Case "xform"
                        Me.btnxForm.Enabled = True
                        Exit Select
                    Case "xform1d"
                        Me.btnxForm1d.Enabled = True
                        Exit Select
                    Case "layermem"
                        Me.btnLayerMem.Enabled = True
                        Exit Select
                    Case "layout"
                        Me.btnLayout.Enabled = True
                        Exit Select
                    Case "text"
                        Me.btnText.Enabled = True
                        Exit Select
                    Case "textxform"
                        Me.btnTxtXForm.Enabled = True
                        Exit Select
                    Case "char"
                        Me.btnChar.Enabled = True
                        Exit Select
                    Case "para"
                        Me.btnParagraph.Enabled = True
                        Exit Select
                    Case "protection"
                        Me.btnProtection.Enabled = True
                        Exit Select
                    Case "event"
                        Me.btnEvent.Enabled = True
                        Exit Select
                    Case "act"
                        Me.btnAction.Enabled = True
                        Exit Select
                    Case "misc"
                        Me.btnMisc.Enabled = True
                End Select

                System.Windows.Forms.Application.DoEvents()

            Next elem

        Catch errXml As XmlException
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(errXml, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        Catch err As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(err, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try

    End Sub

    '
    ' pass in a "shapes" element and look for embedded "shape" elements
    '
    Private Function getShapeChildren(ByVal shapeSource As XElement) As Collection

        Dim colReturn As Collection = New Collection

        Dim qryShapes = shapeSource...<Shape>
        Dim intShapes As Integer = qryShapes.Count

        For Each shape In qryShapes
            colReturn.Add(CLng(shape.@ID))
        Next

        Return colReturn

    End Function


    '
    ' init
    '
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.


        ' init the local variable rather than the property
        Me._xDoc = Nothing

    End Sub

    '
    ' throw not implemented exception
    '
    Private Sub FutureFeature()
        Throw New NotImplementedException
    End Sub

    '
    ' get currently selected shapeid
    '
    Private Sub lvShapes_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles lvShapes.SelectedIndexChanged

        Dim shpItems As ListView.SelectedListViewItemCollection = lvShapes.SelectedItems
        Dim shpItem As ListViewItem

        If 0 < shpItems.Count Then
            shpItem = shpItems(0)
            lngShpId = CLng(shpItem.SubItems(0).Text)
            Me.txtShapeId.Text = CStr(lngShpId)
            strShpName = shpItem.SubItems(1).Text
            Me.txtShpName.Text = strShpName
            strShpNameU = shpItem.SubItems(2).Text
            Me.txtShpNameU.Text = strShpNameU
            Me.txtShpType.Text = strShpType

            getShapeSheetInfo(lngShpId)

        End If

    End Sub

    '
    ' get currently selected page
    '
    Private Sub lvPages_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles lvPages.SelectedIndexChanged

        Dim pgItems As ListView.SelectedListViewItemCollection = lvPages.SelectedItems
        Dim pgItem As ListViewItem
        Dim lngId As Long

        If 0 < pgItems.Count Then

            pgItem = pgItems(0)
            lngPgId = CLng(pgItem.SubItems(0).Text)
            strPgName = pgItem.SubItems(1).Text
            strPgNameU = pgItem.SubItems(2).Text

            ' query the pages

            Dim qryPage = From pageSel In Me.xDoc...<Page> _
                    Where pageSel.@ID = pgItem.SubItems(0).Text
        
            If qryPage.Count = 1 Then
                Me.PgSource = qryPage.First
                getShapes(qryPage.First, Me.lvShapes)
            Else
                MsgBox("could not find page")
            End If ' test that only one page was found
        End If ' test for something selected
    End Sub



#Region " ShapeSheet command buttons "

    '
    ' query shape data / custom properties
    '
    Private Sub btnShapeData_Click(sender As System.Object, e As System.EventArgs) Handles btnShapeData.Click


        frmSectionsLocalData.dataPath = Me.dataPath
        frmSectionsLocalData.xDoc = Me.xDoc
        frmSectionsLocalData.PgSource = Me.PgSource
        frmSectionsLocalData.ShpSource = Me.ShpSource
        frmSectionsLocalData.sectionScratchEnabled = Me.btnScratchData.Enabled
        frmSectionsLocalData.sectionShapeDataEnabled = Me.btnShapeData.Enabled
        frmSectionsLocalData.sectionUserEnabled = Me.btnUserData.Enabled
        frmSectionsLocalData.txtPageId.Text = CStr(lngPgId)
        frmSectionsLocalData.txtShapeId.Text = CStr(lngShpId)

        frmSectionsLocalData.getLocalData()
        frmSectionsLocalData.ShowDialog()

    End Sub

    '
    ' query user data
    '
    Private Sub btnUserData_Click(sender As System.Object, e As System.EventArgs) Handles btnUserData.Click

        frmSectionsLocalData.dataPath = Me.dataPath
        frmSectionsLocalData.xDoc = Me.xDoc
        frmSectionsLocalData.PgSource = Me.PgSource
        frmSectionsLocalData.ShpSource = Me.ShpSource
        frmSectionsLocalData.sectionScratchEnabled = Me.btnScratchData.Enabled
        frmSectionsLocalData.sectionShapeDataEnabled = Me.btnShapeData.Enabled
        frmSectionsLocalData.sectionUserEnabled = Me.btnUserData.Enabled
        frmSectionsLocalData.txtPageId.Text = CStr(lngPgId)
        frmSectionsLocalData.txtShapeId.Text = CStr(lngShpId)


        frmSectionsLocalData.getLocalData()
        frmSectionsLocalData.ShowDialog()

    End Sub

    '
    ' query scratch data
    '
    Private Sub btnScratchData_Click(sender As System.Object, e As System.EventArgs) Handles btnScratchData.Click

        frmSectionsLocalData.dataPath = Me.dataPath
        frmSectionsLocalData.xDoc = Me.xDoc
        frmSectionsLocalData.PgSource = Me.PgSource
        frmSectionsLocalData.ShpSource = Me.ShpSource
        frmSectionsLocalData.sectionScratchEnabled = Me.btnScratchData.Enabled
        frmSectionsLocalData.sectionShapeDataEnabled = Me.btnShapeData.Enabled
        frmSectionsLocalData.sectionUserEnabled = Me.btnUserData.Enabled
        frmSectionsLocalData.txtPageId.Text = CStr(lngPgId)
        frmSectionsLocalData.txtShapeId.Text = CStr(lngShpId)


        frmSectionsLocalData.getLocalData()
        frmSectionsLocalData.ShowDialog()

    End Sub


    '
    '
    '
    Private Sub btnxForm1d_Click(sender As System.Object, e As System.EventArgs) Handles btnxForm1d.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnxForm_Click(sender As System.Object, e As System.EventArgs) Handles btnxForm.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnLayout_Click(sender As System.Object, e As System.EventArgs) Handles btnLayout.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnLayerMem_Click(sender As System.Object, e As System.EventArgs) Handles btnLayerMem.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnText_Click(sender As System.Object, e As System.EventArgs) Handles btnText.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnTxtXForm_Click(sender As System.Object, e As System.EventArgs) Handles btnTxtXForm.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnChar_Click(sender As System.Object, e As System.EventArgs) Handles btnChar.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnParagraph_Click(sender As System.Object, e As System.EventArgs) Handles btnParagraph.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnEvent_Click(sender As System.Object, e As System.EventArgs) Handles btnEvent.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnMisc_Click(sender As System.Object, e As System.EventArgs) Handles btnMisc.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnAction_Click(sender As System.Object, e As System.EventArgs) Handles btnAction.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

    '
    '
    '
    Private Sub btnProtection_Click(sender As System.Object, e As System.EventArgs) Handles btnProtection.Click
        Try
            FutureFeature()
        Catch NotImp As NotImplementedException
            MsgBox(NotImp.Message)
        End Try
    End Sub

#End Region



    '
    '
    '
    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    '
    '
    '
    Private Sub AboutToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        frmAbout.ShowDialog()
    End Sub

    '
    '
    '
    Private Sub btnControl_Click_1(sender As System.Object, e As System.EventArgs) Handles btnControl.Click
        frmSectionsConnections.dataPath = Me.dataPath
        frmSectionsConnections.xDoc = Me.xDoc
        frmSectionsConnections.PgSource = Me.PgSource
        frmSectionsConnections.ShpSource = Me.ShpSource
        frmSectionsConnections.sectionConnPtEnabled = Me.btnConnection.Enabled
        frmSectionsConnections.sectionCtrlPtEnabled = Me.btnControl.Enabled
        frmSectionsConnections.txtPageId.Text = CStr(lngPgId)
        frmSectionsConnections.txtShapeId.Text = CStr(lngShpId)


        frmSectionsConnections.getConnections()
        frmSectionsConnections.ShowDialog()
    End Sub

    '
    '
    '
    Private Sub btnConnection_Click(sender As System.Object, e As System.EventArgs) Handles btnConnection.Click
        frmSectionsConnections.dataPath = Me.dataPath
        frmSectionsConnections.xDoc = Me.xDoc
        frmSectionsConnections.PgSource = Me.PgSource
        frmSectionsConnections.ShpSource = Me.ShpSource
        frmSectionsConnections.sectionConnPtEnabled = Me.btnConnection.Enabled
        frmSectionsConnections.sectionCtrlPtEnabled = Me.btnControl.Enabled
        frmSectionsConnections.txtPageId.Text = CStr(lngPgId)
        frmSectionsConnections.txtShapeId.Text = CStr(lngShpId)


        frmSectionsConnections.getConnections()
        frmSectionsConnections.ShowDialog()
    End Sub

End Class